package cn.ikun.dhj;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class AppAniaml {
    public static void main(String[] args) throws Exception{
        Class<?> aClass = Class.forName("cn.ikun.dhj.Animal");
        Object o = aClass.newInstance();
        Field[] Fields = aClass.getDeclaredFields();
        for (Field field:Fields) {
            Class<?> type = field.getType();
            field.setAccessible(true);
            if (type.toString().endsWith("Integer")){
                field.set(o,19);
            }else if(type.toString().endsWith("String")){
                field.set(o,"Wesang");
            }else if (type.toString().endsWith("Double")){
                field.set(o,2.56);
            }
        }
        Method say = aClass.getDeclaredMethod("say");
//      say.setAccessible(true);
        say.invoke(o);
    }
}
